<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${basePackage}.adapter.driving.persistence.${module}.mapper.${className}Mapper">

  <insert id="insert" useGeneratedKeys="true" keyProperty="id"><#lt>
   INSERT INTO ${tableName}
   (
<#list fields as field>
    <#if field.ignoreInsert == false>
     ${field.columnName}<#if field_has_next>, </#if>
    </#if>
</#list>    )
     VALUES (
<#list fields as field>
  <#if field.ignoreInsert == false>
  <#if field.dateField>
      NOW()<#if field_has_next>, </#if>
  <#else >
      ${"#{"+field.fieldName+"}"}<#if field_has_next>, </#if>
  </#if>
  </#if>
</#list>     )
  </insert>

  <delete id="deleteById" parameterType="Integer">
    DELETE
    FROM ${tableName}
    where id = ${"#{"+_abcde!'value'+"}"}
  </delete>

  <select id="selectById" resultType="${basePackage}.adapter.driving.persistence.${module}.po.${className}Po">
    SELECT
  <#list fields as field>
      ${field.columnName}<#if field_has_next>, </#if>
  </#list>
    FROM ${tableName}
     where id = ${"#{"+_abcde!'value'+"}"}
  </select>

  <update id="updateById">
    UPDATE ${tableName}
     SET
    <#list fields as field>
      <#if field.ignoreUpdate == false>
          <#if field.dateField>
      ${field.columnName} = NOW()<#if field_has_next>, </#if>
          <#else>
      ${field.columnName} = ${"#{"+field.fieldName+"}"}<#if field_has_next>, </#if>
          </#if>
      </#if>
    </#list>
    where id = ${"#{"+_abcde!'id'+"}"}
  </update>

</mapper>
